package com.xbongbong.saas.service.impl;

import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.model.PaasFormModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.BeanUtil;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.mini.dto.MiniInfoGetDTO;
import com.xbongbong.pro.mini.vo.MiniInfoGetVO;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.mini.PluginTypeEnum;
import com.xbongbong.saas.service.MiniHelpInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 应用模块名称<p>
 * 代码描述<p>
 * Company: 逍邦网络科技有限公司<p>
 *
 * @author chenshan
 * @version v1.0
 * @since 2020/10/12 10:14 上午
 */
@Service("miniHelpInfoService")
public class MiniHelpInfoServiceImpl implements MiniHelpInfoService {
    @Resource
    private PaasFormModel paasFormModel;
    @Override
    public MiniInfoGetVO getInfo(MiniInfoGetDTO miniInfoGetDTO) throws XbbException {
        MiniInfoGetVO miniInfoGetVO = new MiniInfoGetVO();
        PaasFormEntityExt paasFormEntityExt = null;
        PluginTypeEnum pluginTypeEnum = PluginTypeEnum.getByCode(miniInfoGetDTO.getType());
        switch (pluginTypeEnum){
            case VISITORS_TO_PLAN:
                paasFormEntityExt = paasFormModel.getByBusinessType(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(),miniInfoGetDTO.getCorpid());
                BeanUtil.copyProperties(paasFormEntityExt,miniInfoGetVO);
                miniInfoGetVO.setFormId(paasFormEntityExt.getId());
                miniInfoGetVO.setIdAdminOrBoss(miniInfoGetDTO.getLoginUser().isAdminOrBoss());
                miniInfoGetVO.setSubBusinessType(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode());
                break;
            case GOOD_NEWS_LIST:
                break;
            case PERFORMANCE_RANKING_LIST:
                break;
            case PERFORMANCE_RANKING_DETAIL:
                break;
            case GOOD_NEWS_DETAIL:
                break;
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100018);
        }
        return miniInfoGetVO;
    }
}
